#ifndef SERVER_H
#define SERVER_H
#ifdef _WIN32
#include <winsock2.h>
#pragma comment(lib,"Ws2_32.lib")
#endif
#ifdef linux
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#endif
#include <exception>
#include <iostream>
#include <string>
#include <algorithm>
#include "data.h"
#include "map.h"
using namespace std;
class server
{
protected :
	int sv_lis;//server listen
	int *cl_con;//client connect
	unsigned int port;//port server
	unsigned int num_cl;//number client
	//string sv_addr;//dia chi server
	string *user;
	map *table;
	int *point;
	unsigned int diamond,gold,silver,stone;
	struct sockaddr_in serv;
	struct sockaddr_in client;
	data sen;
	data rec;
	//khoi tao cac thong so
	void init();

	void getparametter();

	int createsocket();

	int serverlisten();

	int serveraccept();

	int serverbind();
	int serversend(int id);

	void serversendall();

	void serverrecv(int id);
    int login(int id);
	int checkuser(int id);

	void makevaluegame();
	int processresult(int id);

    void playgame();

	void control();
	void serverintro();
	void start();
	void serverclose();

public:
	server();
	~server();
	void run();


};
#endif // SERVER_H
